/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._5BinaryIndexedTree_SegmentTree
 * @File : Q0798.java
 * @Author : WangRuoyu
 * @Date 2023/3/17 22:15
 */

package acwing._2LanQiao._5BinaryIndexedTree_SegmentTree;

import java.io.*;

/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._5BinaryIndexedTree_SegmentTree
 * @File : Q0798.java
 * @Author : WangRuoyu
 * @Date 2023/3/17 22:15
 */

public class Q0798 {
    static int m;
    static int n;
    static int q;
    static long[][] b;

    static void insert(int x1, int y1, int x2, int y2, int c) {
        b[x1][y1] += c;
        b[x2 + 1][y2 + 1] += c;
        b[x1][y2 + 1] -= c;
        b[x2 + 1][y1] -= c;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] words = br.readLine().split(" ");

        m = Integer.parseInt(words[0]);
        n = Integer.parseInt(words[1]);
        q = Integer.parseInt(words[2]);
        b = new long[m + 2][n + 2];

        for (int i = 1; i <= m; i++) {
            words = br.readLine().split(" ");
            for (int j = 1; j <= n; j++) {
                insert(i, j, i, j, Integer.parseInt(words[j - 1]));
            }
        }

        for (int i = 0; i < q; i++) {
            words = br.readLine().split(" ");
            int x1 = Integer.parseInt(words[0]);
            int y1 = Integer.parseInt(words[1]);
            int x2 = Integer.parseInt(words[2]);
            int y2 = Integer.parseInt(words[3]);
            int c = Integer.parseInt(words[4]);
            insert(x1, y1, x2, y2, c);
        }

//        for (int i = 1; i <= m; i++) {
//            for (int j = 1; j <= n; j++) {
//                b[i][j] += b[i][j - 1] + b[i - 1][j] - b[i - 1][j - 1];
//                System.out.print(b[i][j]+" ");
//            }
//            System.out.println();
//        }

        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                b[i][j] += b[i][j - 1] + b[i - 1][j] - b[i - 1][j - 1];
                wr.write(b[i][j]+" ");
            }
            wr.write("\n");
        }
        wr.flush();
    }
}